﻿using System;
using System.IO;
using System.Net;

namespace Caraya.MFG.BillPlugInTests
{
    internal class Program
    {
        static void Main(string[] args)
        {
            try
            {
                var pdfUrl = new Uri("https://wx.g127.com:9008/UploadFiles/background.jpg");
                WebRequest request = WebRequest.Create(pdfUrl);
                using (WebResponse response = request.GetResponse())
                {
                    using (Stream responseStream = response.GetResponseStream())
                    {
                        using (MemoryStream memoryStream = new MemoryStream())
                        {
                            responseStream.CopyTo(memoryStream);
                            byte[] fileData = memoryStream.ToArray();
                            string base64EncodedData = Convert.ToBase64String(fileData);
                            Console.WriteLine(base64EncodedData);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
    }
}